<template>
  <div>计算和: {{ count }}</div>
</template>

<script>
import eventBus from '@/utils/eventBus'
export default {
  name: 'child-2',
  data() {
    return {
      count: 0
    }
  },
  mounted() {
    eventBus.$on('addition', (param) => {
      console.log('param', param)
      this.count = this.count + param.num
    })
  },
  beforeDestroy() {
    console.log('移除事件监听者')
    eventBus.$off('addition')
  }
}
</script>

<style lang="scss" scoped></style>
